package com.yanqu.road.server.cmd.player;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.activity.OldPlayerReturnProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/12/8 15:35
 */
@Cmd(code = CrossProtocol.C_CROSS_BIND_RETURN_ROLE_SUCCESS_RESP, desc = "成功绑定")
public class CrossBindRoleSuccessRespCmd extends CrossCommand {
    private int ret;
    private long oriServerId;
    private long oriUserId;
    private long vipExp;
    private PlayerProto.PlayerBaseTempMsg bindUserInfo;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        OldPlayerReturnProto.BindReturnRoleSuccessRespCrossMsg msg = OldPlayerReturnProto.BindReturnRoleSuccessRespCrossMsg.parseFrom(packet.getBytes());
        ret = msg.getRet();
        oriServerId = msg.getOriServerId();
        oriUserId = msg.getOriUserId();
        vipExp = msg.getVipExp();
        bindUserInfo = msg.getBindUserInfo();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        OldPlayerReturnProto.BindReturnRoleSuccessRespMsg.Builder respMsg = OldPlayerReturnProto.BindReturnRoleSuccessRespMsg.newBuilder();
        respMsg.setRet(ret);
        respMsg.setBindServerId(serverId);
        respMsg.setBindUserId(packet.getPlayerId());
        respMsg.setVipExp(vipExp);
        respMsg.setBindUserInfo(bindUserInfo);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_BIND_RETURN_ROLE_SUCCESS_RESP, respMsg);
        MessageHelper.sendPacket(oriServerId, oriUserId, message);
    }

    @Override
    public void sendData() {

    }
}
